import http from '@/utils/http'
import type { IHotSearch, ISearchGoods } from '@/types/search'

export const reqHotSearch = () => {
  return http<IHotSearch>('xhr/search/init.json', 'get')
}

export const reqSearchGoods = (keword: string, time: number) => {
  return http<ISearchGoods>(
    `xhr/search/search.json?__timestamp=${time}&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=${keword}`,
    'get'
  )
}

export const reqSearch = (keywordPrefix: string) => {
  return http<string[]>(
    `xhr/search/searchAutoComplete.json?keywordPrefix=${keywordPrefix}&csrf_token=11815d8421e0708af5627f5fa6fba9c4`,
    'post'
  )
}
